/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include <random>
#include <向量.h>

#include <基本类型.h>







inline int32	f_get随机IntRange(int32 x, int32 y)		{ return rand() % (y - x + 1) + x; }
inline uint32	f_get随机UIntRange(uint32 x, uint32 y)	{ return rand() % (y - x + 1) + x; }

//返回 0 ~ 1 的随机数
inline double	f_get随机Float32() { return (rand()) / (RAND_MAX + 1.0); }

Inline bool f_get随机Bool() {
	if (f_get随机IntRange(0, 1)) return true;
	else return false;
}

//returns a random float in the range -1 < n < 1
Inline double f_get随机Clamped() { return f_get随机Float32() - f_get随机Float32(); }


int32 f_random_I32(ivec2 区间 = { 0,1 }, int32 随机种子 = 0);
float32 f_random_F32(int32 随机种子 = 0, vec2 区间 = {0,1});





template<typename T>
Inline void f_随机打乱(T& data, int64 种子) {
	//uniform_int_distribution<unsigned> u(0, max);
	std::default_random_engine e;
	e.seed(种子);

	std::shuffle(data.begin(), data.end(), e);

}








vec3 f_随机向量(int64 种子, vec2 范围);


void f_随机向量(std::vector<vec3>& vec, uint64 num, vec2 范围, int32 种子, const vec3& s = { 1.0f,1.0f,1.0f });
void f_随机向量(std::vector<vec3>& vec, uint64 num, vec2 X, vec2 Y, vec2 Z, int32 种子);
void f_随机向量(std::vector<vec2>& vec, uint64 num, vec2 范围, int32 种子, const vec2& s = { 1.0f,1.0f });
void f_随机向量(std::vector<float32>& vec, uint64 num, vec2 范围, int64 种子);
void f_随机向量(std::vector<S_VecSphere>& vec, uint64 num, const S_VecSphere& 最小, const S_VecSphere& 最大, int32 种子);


vec2 f_随机_向量(float32 最小范围, float32 最大范围, int32 种子);



void f_random_不重复随机数(int32 最小, int32 最大);


